home *** CD-ROM | disk | FTP | other *** search
- Program xlat;
- uses BOSHARE, Crt;
-
- var
- s : String;
-
- BEGIN
-
- Writeln('< Adventures with Boosters'' Translate function >');
- Writeln;
-
- { change all occurrences of one character to another }
- s := 'Lo and behold! It looks like rain!';
- writeln( s );
- writeln( translate(s,'!','.','.'));
- readln;
-
- s := 'Niagara-Falls,-New-York Green-Bay,-Wisconsin';
- writeln( s );
-
- { insert CR/LF }
- Insert ( #13#10, s, pos(' ',s)+1 );
-
- { change separation characters to blanks }
- s := translate( s, '-',' ', ' ');
- writeln( s );
- readln;
-
- { remove CR/LF }
- s := translate( s, #13#10,'',' ');
- writeln( s );
- readln;
-
- { re-order characters in a string of non-duplicates }
- s := 'orlandB';
- writeln(s);
- s := translate ( s, s, 'Borland', ' ');
- writeln( s );
- readln;
-
- { using the Pad character }
- writeln;
- writeln( translate( 'aei','eia','12','$' ) );
- readln;
-
- { emulating the strip function }
- writeln;
- s := '--------123456--------';
- writeln(s);
- writeln( translate( s,'-','',' ') );
- readln;
-
- { null input table }
- writeln;
- s := 'liftoff';
- Writeln(s);
- writeln( translate( 'liftoff','','123',' ') );
- readln;
-
- { null input table and null output table }
- Writeln;
- Writeln(s);
- writeln( translate( s,'','',' ') );
- readln;
-
- { using the Pad character }
- writeln;
- s := 'Dollars and Sense';
- Writeln(s);
- writeln( translate( s,'sS','$','$' ) );
- readln;
-
- END.